package UI;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import Core.Simulation;


public class MenuElements extends JPanel{
	
	private Grille _grille;
	private JPanel _elements;
	private Color _colorPousse = Color.decode("#8FCF3C");
	private Color _colorArbuste = Color.decode("#556627");
	private Color _colorArbre = Color.decode("#036635");
	private Color _colorFeu = Color.decode("#B9121B");
	private Color _colorInsecte = Color.decode("#50468C");
	private Fenetre fenetre;
    private int x = 0;
    private int y = 0;
    private int _choixX =0;
	
	public MenuElements(Grille grille, Fenetre _fenetre) {
		this._grille = grille;
		this.fenetre = _fenetre;
    	x = fenetre.ret_x();
    	 y = fenetre.ret_y();
		
	}
	
	public void setChoix(int choixTemp)
    {
    	_choixX = choixTemp;
    }
	
	public JPanel MenuElemnts ()
	{
		_elements = new JPanel();
		_elements.setLayout(null);
		_elements.setBounds(fenetre.ret_x()+50, 440, 250, 400);
		_elements.setVisible(true);
		
		
		//BOUTON 1
		JLabel _ex = new JLabel();
		_ex.setText("Jeunes pousse");
		_ex.setBounds(30, 5, 100, 20);
		_elements.add(_ex);
		
		JButton _pousse = new JButton();
		_pousse.setBounds(5, 5, 20, 20);
		_pousse.setBackground(_colorPousse);
		_pousse.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				_grille.SetCouleur("#8FCF3C");
				_grille.SetEtat(1);
			}
		});
		_elements.add(_pousse);
		
		
		//BOUTON 2
		JLabel _ex1 = new JLabel();
		_ex1.setText("Arbuste");
		_ex1.setBounds(30, 30, 100, 20);
		_elements.add(_ex1);
		
		JButton _arbuste = new JButton();
		_arbuste.setBounds(5, 30, 20, 20);
		_arbuste.setBackground(_colorArbuste);
		_arbuste.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				_grille.SetCouleur("#556627");
				_grille.SetEtat(2);
			}
		});
		_elements.add(_arbuste);
		
		//BOUTON 3
		JLabel _ex2 = new JLabel();
		_ex2.setText("Arbre");
		_ex2.setBounds(30, 55, 100, 20);
		_elements.add(_ex2);
		
		JButton _arbre = new JButton();
		_arbre.setBounds(5, 55, 20, 20);
		_arbre.setBackground(_colorArbre);
		_arbre.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				_grille.SetCouleur("#036635");
				_grille.SetEtat(3);
			}
		});
		_elements.add(_arbre);
		
		
		//BOUTON 4
		JLabel _ex3 = new JLabel();
		_ex3.setText("Feu");
		_ex3.setBounds(30, 80, 100, 20);
		_elements.add(_ex3);
		
		JButton _feu = new JButton();
		_feu.setBounds(5, 80, 20, 20);
		_feu.setBackground(_colorFeu);
		_feu.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				_grille.SetCouleur("#B9121B");
				_grille.SetEtat(4);
			}
		});
		if((_choixX == 3) || (_choixX == 1))
		{
			_ex3.setVisible(false);
			_feu.setVisible(false);
		}
		_elements.add(_feu);
		
		//BOUTON 5
		JLabel _ex4 = new JLabel();
		_ex4.setText("Insecte");
		_ex4.setBounds(30, 80, 100, 20);
		_elements.add(_ex4);
		
		JButton _insecte = new JButton();
		_insecte.setBounds(5,80, 20, 20);
		_insecte.setBackground(_colorInsecte);
		_insecte.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				_grille.SetCouleur("#50468C");
				_grille.SetEtat(5);
			}
		});
		if((_choixX == 2 ) || (_choixX == 1)) 
		{
			_ex4.setVisible(false);
			_insecte.setVisible(false);
		}
		_elements.add(_insecte);
		

	
	return _elements;
	}
}
